home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / newlooklib.lha / newlook / docyclebutton.c < prev    next >
C/C++ Source or Header  |  1993-10-03  |  801b  |  30 lines

  1. /*
  2.  *  DOCYCLEBUTTON.C
  3.  */
  4.  
  5. #include "newlook.h"
  6.  
  7. extern LONG IntuiTextLength(struct IntuiText *);
  8. extern UWORD AddGadget( struct Window *, struct Gadget *, UWORD );
  9. extern VOID RefreshGList( struct Gadget *, struct Window *, struct Requester *, UWORD );
  10.  
  11. void DoCycleButton(w,g)
  12. struct Window *w;
  13. struct Gadget *g;
  14. {
  15.   if(w && g && g->UserData)
  16.   {
  17.     USHORT pos= RemoveGadgetSafely(w,g);
  18.     struct CycleInfo *ci= (struct CycleInfo *)g->UserData;
  19.     struct IntuiText *it= ci->ci_IntuiText;
  20.  
  21.     if(!(it->IText=ci->ci_Items[++ci->ci_CurrentIndex]))
  22.       it->IText= ci->ci_Items[ci->ci_CurrentIndex=0];
  23.     it->LeftEdge= (g->Width+21-IntuiTextLength(it))/2;
  24.  
  25.     if(pos!=0xFFFF) /* 0xFFFF == (-1)  did we really remove the gadget? */
  26.       AddGadget(w,g, pos);
  27.     RefreshGList(g,w,NULL,1L);
  28.   }
  29. }
  30.